// 优惠券
import http from "@/utils/request";
// 获取门禁列表
export const getCoupon = async (data) => {
	return http.get<any>('/member/coupon/coupons', data)
}
/**
 * 从详情或列表中某一条数据解析优惠内容
 * @param CouponDetail v
 * @returns
 */
export function transformPreferentialContent(v) {
	let pieces : string[] = []
	if (v.couponType == 2) {
		if (v.preferentialContentType == 0) {
			pieces.push(`新客立减${v.marginPreference}元`)
		} else {
			pieces.push(`新客打${v.marginPreference}折`)
		}
		if (v.preferentialContentTypeOld == 0) {
			pieces.push(`老客立减${v.marginPreferenceOld}元`)
		} else {
			pieces.push(`老客打${v.marginPreferenceOld}折`)
		}
	} else {
		let prefix = ''
		if (v.couponType == 3) {
			prefix = '每期账单'
		}
		if (v.preferentialContentType == 0) {
			pieces.push(`${prefix}立减${v.marginPreference}元`)
		} else {
			pieces.push(`${prefix}打${v.marginPreference}折`)
		}
	}
	return pieces.join('；')
}